Skip to content

Bring the image upload (PR #2) into master - #4

Merged
jvmvik merged 4 commits into
masterfrom
merge-image-api
Nov 5, 2026
Merged

jvmvik merged 4 commits into
masterfrom
merge-image-api

Conversation

@jvmvik

@jvmvik jvmvik commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

PR #2 (image-api) was merged into parity-fixes, not master. It landed 29 seconds after PR #1 had already merged parity-fixes into master, so uploadImage never reached master.

This merges origin/parity-fixes (b617d9e + merge e0ad0a9) into the current master. There were no conflicts: CHANGELOG.md and README.md auto-merged cleanly.

Brings in:

  • uploadImage / uploadImageBytes (+ typed *As variants) for the Image API
  • error.ImageTooLarge in serpapi.Error
  • README section "Google Lens with File Upload", CHANGELOG entries, OOBT image upload, integration tests
  • Clear lastError at the start of an image upload (cherry-picked 30231d8): a file error returned before fetch left lastError() describing an earlier request

Tests: zig build test: 42/42 pass.

🤖 Generated with Claude Code

jvmvik and others added 4 commits November 3, 2026 14:54
uploadImage(path, params) and uploadImageBytes(bytes, file_name, params),
plus the typed uploadImageAs / uploadImageBytesAs, POST the image to
https://serpapi.com/image as multipart/form-data and return its image_id
for engines such as Google Lens. Ported from serpapi-rust's image-api.

- the image goes in field `image`, filename kept (quotes and CR/LF
  escaped), content type sniffed from the JPEG/PNG/WebP signature, then
  the extension
- api_key and source travel in the body, never in the URL; constructor
  search defaults (engine, output, ...) are not sent; a call param named
  `image` is a compile error
- images over 500 KiB are rejected with error.ImageTooLarge before being
  read or sent
- the upload shares fetch with every GET: the timeout race, the status
  check, the error payload rule, and lastError(), whose url is
  https://serpapi.com/image for a failed upload
- live tests: upload from a file and from bytes, invalid image, invalid
  key, then a google_lens search on the uploaded image; oobt also uploads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add uploadImage for the Image API (F7)
AI: Claude Opus 5.5 · effort unknown · main session: fixed reviewer finding 1 (stale lastError after a file error in uploadImage), with a unit test that fails without the fix

A file error in uploadImage (missing file, unreadable path) returns before
fetch, which is where every other request clears the previous failure, so
lastError() kept describing an earlier, unrelated request. That contradicts
the 1.2.0 behavior change: errorMessage() and lastError() describe the most
recent request only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvmvik
jvmvik merged commit 4d32ba6 into master Nov 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant